// PART 5 PRODUCES RESULTS FOR TABLE 11

clear
cd "\\file\UsersW$\wrr15\Home\My Documents\My Files\XINDONG XUE\META-ANALYSIS\REVISION FOR JHE\DATA AND CODE"
set more off
set type double
graph drop _all
program drop _all
set scheme s2mono
log using "Part5 Results(20191130).smcl", replace
use "sc_data(20191130).dta"

// THIS SECTION PRODUCES THE RESULTS FOR TABLE 11

******************************************************************************
*DEFINITION OF BASIC VARIABLES
******************************************************************************
gen tstat = real(tstatistics)
gen negative = 1
replace negative = -1 if ((badhealth == 1 & badsc == 0) | (badhealth == 0 & badsc == 1))
replace tstat = tstat*negative
gen df = nobs
gen obsno = _n
replace df = . if tstat == .
gen r = tstat/sqrt(tstat^2+df)
gen varR = (1-r^2)/df
gen seR = sqrt(varR)
gen pcc = r

quietly summ pcc, detail
keep if pcc > r(p1) & pcc < r(p99) 

**************************************************
*****FINER CATEGORIZATIONS OF SOCIAL CAPITAL******
**************************************************
foreach x in "social trust" "perceived social support" "perceived social cohension" "perceived reciprocity" "sense of belonging" "loneliness" "social participation" "social networks" "social support" "social engagement" "volunteering" "group membership" "social integration" "social relationship" {
scalar VARNAME = "`x'"
scalar list VARNAME
summ pcc if scname_new == "`x'"
preserve
gen tstatnew = 0 if scname_new == "`x'"
replace tstatnew = 1 if tstat<-2 & scname_new == "`x'"
replace tstatnew = 2 if (tstat>=-2 & tstat<=2) & scname_new == "`x'"
replace tstatnew = 3 if (tstat>2) & scname_new == "`x'"
tab tstatnew
restore
}

************************************
************************************
************************************
************ TABLE 11 **************
************************************
************************************
************************************

******************************************
*****FINER CATEGORIZATIONS OF HEALTH******
******************************************

gen disease_illness = 0
replace disease_illness = 1 if healthvariables == "hypertension"
replace disease_illness = 1 if healthvariables == "diabetes"
replace disease_illness = 1 if healthvariables == "Number of Chronic Health"
replace disease_illness = 1 if healthvariables == "All circulatory system disease"
replace disease_illness = 1 if healthvariables == "Non-cancer and non-circulatory system.."
replace disease_illness = 1 if healthvariables == "presence of LLI"
replace disease_illness = 1 if healthvariables == "All cancer"
replace disease_illness = 1 if healthvariables == "Cerebrovascular disease"
replace disease_illness = 1 if healthvariables == "cardiovascular"
replace disease_illness = 1 if healthvariables == "Cancer"
replace disease_illness = 1 if healthvariables == "Ischaemic heart disease"
replace disease_illness = 1 if healthvariables == "stroke"
replace disease_illness = 1 if healthvariables == "Cardiovascular disease"
replace disease_illness = 1 if healthvariables == "Musculoskeletal disorders"
replace disease_illness = 1 if healthvariables == "cancer"
replace disease_illness = 1 if healthvariables == "long-term sickness absences"
replace disease_illness = 1 if healthvariables == "Hypertension"
replace disease_illness = 1 if healthvariables == "IHD"
replace disease_illness = 1 if healthvariables == "ADL disabled"
replace disease_illness = 1 if healthvariables == "IADL disabled"
replace disease_illness = 1 if healthvariables == "chronic diseases"
replace disease_illness = 1 if healthvariables == "Crp"
replace disease_illness = 1 if healthvariables == "Fatal coronary heart disease"
replace disease_illness = 1 if healthvariables == "Fibrinogen"
replace disease_illness = 1 if healthvariables == "Serum Albumin"
replace disease_illness = 1 if healthvariables == "Total cancer"
replace disease_illness = 1 if healthvariables == "CHD"
replace disease_illness = 1 if healthvariables == "cardiovasular disease"
replace disease_illness = 1 if healthvariables == "cirrhosis"
replace disease_illness = 1 if healthvariables == "emphysema or copd"
replace disease_illness = 1 if healthvariables == "heart attack"
replace disease_illness = 1 if healthvariables == "heart failure"
replace disease_illness = 1 if healthvariables == "ischemic heart disease"
replace disease_illness = 1 if healthvariables == "number of disease"
replace disease_illness = 1 if healthvariables == "thyroid problems"
replace disease_illness = 1 if healthvariables == "ulcers"
replace disease_illness = 1 if healthvariables == "cachexia"
replace disease_illness = 1 if healthvariables == "cardiac"
replace disease_illness = 1 if healthvariables == "Cardiovascular disease (stroke and co.."
replace disease_illness = 1 if healthvariables == "Chronic lower respiratory diseases"
replace disease_illness = 1 if healthvariables == "Coronary heart disease"
replace disease_illness = 1 if healthvariables == "Non fatal myocardial infarction"
replace disease_illness = 1 if healthvariables == "Non fatal stroke"
replace disease_illness = 1 if healthvariables == "Non-sudden cardiac death"
replace disease_illness = 1 if healthvariables == "Nonfatal myocardial infarction"
replace disease_illness = 1 if healthvariables == "Stroke"
replace disease_illness = 1 if healthvariables == "Total coronary heart disease"
replace disease_illness = 1 if healthvariables == "Total stroke"
replace disease_illness = 1 if healthvariables == "Toul coronary heart disease"
replace disease_illness = 1 if healthvariables == "year-long illness scores"
replace disease_illness = 1 if healthvariables == "C-reactive protein"
replace disease_illness = 1 if healthvariables == "Heart disease"
replace disease_illness = 1 if healthvariables == "Malignant neoplasms"
replace disease_illness = 1 if healthvariables == "Serum fibrinogen"
replace disease_illness = 1 if healthvariables == "cerebrovascular disease"
replace disease_illness = 1 if healthvariables == "respiratort diseases"
replace disease_illness = 1 if healthvariables == "cancer-breast"
replace disease_illness = 1 if healthvariables == "cancer-lung"
replace disease_illness = 1 if healthvariables == "heart disease-adjusted for poverty"
replace disease_illness = 1 if healthvariables == "heart disease-unadjusted"
replace disease_illness = 1 if healthvariables == "illness and injury"
replace disease_illness = 1 if healthvariables == "malignant neoplasms-adjusted for pove.."
replace disease_illness = 1 if healthvariables == "malignant neoplasms-unadjusted"
replace disease_illness = 1 if healthvariables == "number of chronic disease"
replace disease_illness = 1 if healthvariables == "long-term limiting illness"
replace disease_illness = 1 if healthvariables == "recurrence of acute coronary sydrome"
replace disease_illness = 1 if healthvariables == "chronic illness all"
replace disease_illness = 1 if healthvariables == "chronic illness hypertension"
replace disease_illness = 1 if healthvariables == "Type 2 diabetes"
replace disease_illness = 1 if healthvariables == "Type 3 diabetes"
replace disease_illness = 1 if healthvariables == "Type 4 diabetes"
replace disease_illness = 1 if healthvariables == "Type 5 diabetes"
replace disease_illness = 1 if healthvariables == "Type 6 diabetes"
replace disease_illness = 1 if healthvariables == "Type 7 diabetes"
replace disease_illness = 1 if healthvariables == "diabetes duration"
sum disease_illness


replace mortality = 0
replace mortality = 1 if healthvariables == "mortality"
replace mortality = 1 if healthvariables == "all-cause mortality"
replace mortality = 1 if healthvariables == "Mortality"
replace mortality = 1 if healthvariables == "mortality risk"
replace mortality = 1 if healthvariables == "risk of dying"
replace mortality = 1 if healthvariables == "suicide mortality"
replace mortality = 1 if healthvariables == "all-caused mortality"
replace mortality = 1 if healthvariables == "all-cause mortality"
replace mortality = 1 if healthvariables == "mortality-male"
replace mortality = 1 if healthvariables == "All-causes mortality"
replace mortality = 1 if healthvariables == "Mortality"
replace mortality = 1 if healthvariables == "Death"
replace mortality = 1 if healthvariables == "cardiovascular disease mortality"
replace mortality = 1 if healthvariables == "All-cause Mortality"
replace mortality = 1 if healthvariables == "cardiovascular mortality"
replace mortality = 1 if healthvariables == "probility of dying"
replace mortality = 1 if healthvariables == "the risk of mortality"
replace mortality = 1 if healthvariables == "Total mortality"
replace mortality = 1 if healthvariables == "time to death:older cohort"
replace mortality = 1 if healthvariables == "All-cause mortality"
replace mortality = 1 if healthvariables == "Cancer-cause mortality"
replace mortality = 1 if healthvariables == "Heart disease-cause mortality"
replace mortality = 1 if healthvariables == "death"
replace mortality = 1 if healthvariables == "mortality-men"
replace mortality = 1 if healthvariables == "mortality"
replace mortality = 1 if healthvariables == "total mortality"
replace mortality = 1 if healthvariables == "mortality-women"
replace mortality = 1 if healthvariables == "Trends in mortality"
replace mortality = 1 if healthvariables == "Cancer mortality"
replace mortality = 1 if healthvariables == "Chronic lower respiratory diseases mo.. "
replace mortality = 1 if healthvariables == "Coronary heart disease mortality"
replace mortality = 1 if healthvariables == "Psychiatric disorders mortality"
replace mortality = 1 if healthvariables == "Stroke mortality"
replace mortality = 1 if healthvariables == "Suicide mortality"
replace mortality = 1 if healthvariables == "Type 2 diabetes mortality"
replace mortality = 1 if healthvariables == "all cause mortality"
replace mortality = 1 if healthvariables == "all-cause death rates"
replace mortality = 1 if healthvariables == "morality"
replace mortality = 1 if healthvariables == "Sudden cardiac death"
replace mortality = 1 if healthvariables == "heart disease death rates"
replace mortality = 1 if healthvariables == "other cause death rates"
replace mortality = 1 if healthvariables == "completed suicides"
replace mortality = 1 if healthvariables == "CVD�mortality"
replace mortality = 1 if healthvariables == "Other mortality"
replace mortality = 1 if healthvariables == "cause specific mortality"
replace mortality = 1 if healthvariables == "time to death:younger cohort"
replace mortality = 1 if healthvariables == "All cancer mortality"
replace mortality = 1 if healthvariables == "cancer-cause mortality"
replace mortality = 1 if healthvariables == "cardiovascular  mortality"
replace mortality = 1 if healthvariables == "cardiovascular disease-cause mortality"
replace mortality = 1 if healthvariables == "infant death"
replace mortality = 1 if healthvariables == "suicide-cause mortality"
replace mortality = 1 if healthvariables == "unintentional injury-cause mortality"
replace mortality = 1 if healthvariables == "CVD Mortality"
replace mortality = 1 if healthvariables == "Total Mortality"
replace mortality = 1 if healthvariables == "all-cause mortality-Europe-ANZ"
replace mortality = 1 if healthvariables == "all-cause mortality-Japan"
replace mortality = 1 if healthvariables == "all-cause mortality-North American"
replace mortality = 1 if healthvariables == "cancer mortality"
replace mortality = 1 if healthvariables == "15-year mortality-men"
replace mortality = 1 if healthvariables == "15-year mortality-women"
replace mortality = 1 if healthvariables == "age-adjusted cardiovascualr mortality.. "
replace mortality = 1 if healthvariables == "all-cause mortality ADL Impaired"
replace mortality = 1 if healthvariables == "all-cause mortality ADL Unimpaired"
replace mortality = 1 if healthvariables == "male mortality"
replace mortality = 1 if healthvariables == "survival"
replace mortality = 1 if healthvariables == "All causes mortality"
replace mortality = 1 if healthvariables == "female life expectancy"
replace mortality = 1 if healthvariables == "female mortality"
replace mortality = 1 if healthvariables == "female mortality(FCIRC94) "
replace mortality = 1 if healthvariables == "female mortality(FEXT94) "
replace mortality = 1 if healthvariables == "female mortality(FLIFEX94) "
replace mortality = 1 if healthvariables == "female mortality(FNEO94) "
replace mortality = 1 if healthvariables == "male mortality(MCIRC94) "
replace mortality = 1 if healthvariables == "male mortality(MEXT94) "
replace mortality = 1 if healthvariables == "male mortality(MLIFEX94) "
replace mortality = 1 if healthvariables == "male mortality(MNEO94) "
replace mortality = 1 if healthvariables == "mortality rates-females"
replace mortality = 1 if healthvariables == "mortality rates-males"
replace mortality = 1 if healthvariables == "mortality rates-total"
replace mortality = 1 if healthvariables == "all-cause mortality-high urbanization.. "
replace mortality = 1 if healthvariables == "all-cause mortality-low urbanization .. "
replace mortality = 1 if healthvariables == "all-cause mortality-married"
replace mortality = 1 if healthvariables == "all-cause mortality-medium urbanizati.. "
replace mortality = 1 if healthvariables == "all-cause mortality-men"
replace mortality = 1 if healthvariables == "all-cause mortality-non married"
replace mortality = 1 if healthvariables == "all-cause mortality-non-western ethic.. "
replace mortality = 1 if healthvariables == "all-cause mortality-western ethic ori.. "
replace mortality = 1 if healthvariables == "all-cause mortality-women"
replace mortality = 1 if healthvariables == "cardiovascular disease mortality"
replace mortality = 1 if healthvariables == "external causes-suicide"
replace mortality = 1 if healthvariables == "infant mortality-adjusted for poverty"
replace mortality = 1 if healthvariables == "infant mortality-unadjusted"
replace mortality = 1 if healthvariables == "other-cause mortality"
replace mortality = 1 if healthvariables == "pulmonary disease mortality"
replace mortality = 1 if healthvariables == "total mortality-adjusted for poverty"
replace mortality = 1 if healthvariables == "total mortality-unadjusted"
replace mortality = 1 if healthvariables == "Mortality per 100,000"
replace mortality = 1 if healthvariables == "accident mortality"
replace mortality = 1 if healthvariables == "heart mortality"
replace mortality = 1 if healthvariables == "infant mortality"
replace mortality = 1 if healthvariables == "total mortality"
replace mortality = 1 if healthvariables == "violence-related morality rate"
replace mortality = 1 if healthvariables == "cancer-mortality"
replace mortality = 1 if healthvariables == "cardiovascular-mortality"
replace mortality = 1 if healthvariables == "other disease-mortality"
replace mortality = 1 if healthvariables == "other external-mortality"
replace mortality = 1 if healthvariables == "percentage of total morality that is .. "
replace mortality = 1 if healthvariables == "self-inflicted injury mortality"
replace mortality = 1 if healthvariables == "suicide-mortallity"
replace mortality = 1 if healthvariables == "Fatal stroket"
replace mortality = 1 if healthvariables == "Risk of 10-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 11-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 12-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 13-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 14-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 15-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 16-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 17-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 18-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 19-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 20-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 21-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 22-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 23-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 24-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 25-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 26-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 27-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 28-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 29-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 30-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 31-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 32-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 33-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 34-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 35-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 36-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 37-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 38-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 39-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 40-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 41-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 42-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 43-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 44-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 45-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 46-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 47-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 48-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 49-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 50-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 51-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 52-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 53-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 54-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 55-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 56-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 57-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 58-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 8-Year Mortality"
replace mortality = 1 if healthvariables == "Risk of 9-Year Mortality"
replace mortality = 1 if healthvariables == "percentage of total morality that is .. "
replace mortality = 1 if healthvariables == "mortality rate"
sum mortality

gen depression = 0
replace depression = 1 if healthvariables == "depression"
replace depression = 1 if healthvariables == "Depression"
replace depression = 1 if healthvariables == "depressive mood"
replace depression = 1 if healthvariables == "major depression"
replace depression = 1 if healthvariables == "depression symptoms"
replace depression = 1 if healthvariables == "depressive"
replace depression = 1 if healthvariables == "Depressive Symptoms"
replace depression = 1 if healthvariables == "T3 depression"
replace depression = 1 if healthvariables == "Depression symptoms"
replace depression = 1 if healthvariables == "Antidepressant treatment"
replace depression = 1 if healthvariables == "antidepressant treatment"
replace depression = 1 if healthvariables == "anxiety/depression"
replace depression = 1 if healthvariables == "Geriatric Depression scale"
replace depression = 1 if healthvariables == "depressive symptoms"
replace depression = 1 if healthvariables == "self-rating depression scale"
replace depression = 1 if healthvariables == "Depressed Mood"
replace depression = 1 if healthvariables == "depressive symptom"
replace depression = 1 if healthvariables == "level of depression"
replace depression = 1 if healthvariables == "depressed"
replace depression = 1 if healthvariables == "depressive symptomes"
replace depression = 1 if healthvariables == "Depressive symptom"
replace depression = 1 if healthvariables == "depressive symptoms:Sweden men"
replace depression = 1 if healthvariables == "depressive symptoms:Sweden women"
replace depression = 1 if healthvariables == "depressive symptoms:Ukraine men"
replace depression = 1 if healthvariables == "depressive symptoms:Ukraine women"
replace depression = 1 if healthvariables == "dizygotic major depression"
replace depression = 1 if healthvariables == "dizygotic number of depressive symptoms"
replace depression = 1 if healthvariables == "monozygotic major depression"
replace depression = 1 if healthvariables == "monozygotic number of depressive symp.. "
replace depression = 1 if healthvariables == "mumber of depressive symptoms"
replace depression = 1 if healthvariables == "Depressive Mood"
replace depression = 1 if healthvariables == "anxiety/depression(females) "
replace depression = 1 if healthvariables == "anxiety/depression(males) "
replace depression = 1 if healthvariables == "mental status(CMD5,anxiety,depression) "
replace depression = 1 if healthvariables == "mental status(only by depression) "
replace depression = 1 if healthvariables == "often felt depressed"
sum depression

foreach x in mortality disease_illness depression {
scalar VARNAME = "`x'"
scalar list VARNAME
summ pcc if `x' == 1
preserve
gen tstatnew = 0 if `x' == 1
replace tstatnew = 1 if tstat<-2 & `x' == 1
replace tstatnew = 2 if (tstat>=-2 & tstat<=2) & `x' == 1
replace tstatnew = 3 if (tstat>2) & `x' == 1
tab tstatnew
restore
}

summ pcc if physicalhealth==1 & selfreported==1
summ pcc if mentalhealth==1 & selfreported==1

log close

 